import { observable, action, toJS } from 'mobx';
import * as API from '../../apis/agent'
import { Browser, SearchAdvanced, Form, SearchPage, ListPage, RouteLayout, ListViewPage } from 'weaver-mobile-page'
import cloneDeep from 'lodash/cloneDeep';
import { Bubble, Tools, Modal } from 'weaver-mobile'
import * as EmSDK from '../../util/emSDK';

const getLabel = Tools.getLabel;
// 我的代理 我代处理的流程 交办他人的流程 全部
const initDatas = {
    list: new ListPage.Store(),
    search: new SearchAdvanced.Store({ route: '/agent/mineAgentSet' }),
    listViewPage_listsotre14: new ListViewPage.Store({ route: '/agent/mineAgentSet', id: '/agent/mineAgentSet' }),
    listViewPage_listsotre23: new ListViewPage.Store({ route: '/agent/mineAgentSet', id: '/agent/mineAgentSet' }),
    nowPath: "/agent/mineAgentSet",
    isShowCheck: false,
    propsVisiable: false,//props的显隐
    listParams: { "agented": 0, "agentFlag": 0 },
    batchEditDatas: {},
    batchEditForm: new Form.Store(),
    batchEditOrBatchReceive: 0,//0 批量编辑 1 批量收回
    batchShowCheckModal: false,//冲突提示
    batChradioChecked: 1,
    batchModalTitle: "",
    batchEditParams: {},
    batch_isShowLoading: false,
    selectedRowKeys: [],//批量编辑或者批量收回选中的值
    comparelengthData: [],///可选的data数量
    radioChecked: true,//代理设置收回确认是否选中
    checkDatas: [],
    datasTab0: [],
    datasTab1: [],
    datasTab2: [],
    datasTab3: [],
    searchPage: new SearchPage.Store({ route: "/agent/mineAgentSet", id: "agentSearch" }),
    layout_batchEdit: new RouteLayout.Store({ route: "/agent/mineAgentSet", id: "batchEdit" }),
    searchValue: "",
    isSearching: false,
    isSelectedAll: false,
    isShowSearchPage: false,
    isShowLoading: false,
    beginDate: null,
    beginTime: null,
    endDate: null,
    endTime: null,
    promptmsg: '',
    searchParams: {},//j记录下搜索条件
    isAdVancedHasData: false,//高级搜索中是否输入了值
    // defaultAdvancedValue: {},
}
//新建代理 新建模板 编辑模板 从模板导入并新建代理 这几个页面的store
const initAddAgent = {
    symbol: "",
    templateid: 0,
    datas: {},//请求到的结果
    form: new Form.Store(),
    isInAddAgent: false,//默认一开始没有再这个页面
    browserStore: new Browser.Store({ route: '/agent/addAgent', id: 'templates' }),
    layout: new RouteLayout.Store({ route: '/agent/addAgent', id: 'saveAsTemplate' }),
    layout_SelectIdentatity: new RouteLayout.Store({ route: '/agent/addAgent', id: 'selectIdentatity' }),
    list_selectIdentatity: new ListPage.Store(),
    bagentuid_identatity: { key: "all", showname: getLabel(500409, "全部身份") },
    selectIdentatity_data: [],
    default_bagentuid: "",
    isShowLoading: false,
    beginDate: null,
    endDate: null,
    beginTime: null,
    endTime: null,
    isShowCheckModal: false,
    title: "",//重复代理询问的标题
    radioChecked: 1,
    savePramas: {},//重复代理询问确认新建代理时拿到的值
}
/**存为模板 */
const initSaveAsTem = {
    form: new Form.Store(),
}
//模板管理 的store
const initTempManagement = {
    form: new Form.Store(),
    isShowCheck: false,
    propsVisiable: false,
    datas: [],
    searchParams: {},
    selectedRowKeys: [],
    searchValue: "",
    isSelectedAll: false,
    isShowLoading: false,
    isAdVancedHasData: false,
    listViewPage_listsotre: new ListViewPage.Store({ route: '/agent/temManagement', id: '/agent/temManagement' }),
}
//高级搜索
const initAdvancedItem = {
    form: new Form.Store(),
    parentPath: "",
    conditioninfo: [],
    formValue: {},
}

//从模板导入
const initInportFromTem = {
    form: new Form.Store(),
    datas: [],
    selectedRowKeys: "",
    searchValue: "",
    isAdvancedSearching: false,
    searchParams: {},
    isShowLoading: false,
    isShowCheck: true,
    listViewPage_listsotre: new ListViewPage.Store({ route: '/agent/importFromTem', id: '/agent/importFromTem' }),
}

//编辑代理
const initEditAgent = {
    form: new Form.Store({ route: "/agent/editAgent" }),//表单数据
    detailForm: new Form.Store(),
    datas: [],//表格数据
    fields: {},
    getDataParams: {},
    selectedRowKeys: [],
    conditioninfo: [],
    hasRequiredItem: {},
    switchOffAllItem: {},
    detailDataId: 0,
    isHasPre: false,//是否有上一行
    isHasNext: false,//是否有下一行
    agentid: "",
    isSelectedAll: false,
    parentPath: "",
    beginDate: null,
    beginTime: null,
    endDate: null,
    endTime: null,
    isShowLoading: false,
    isShowCheckModal: false,
    title: "",//重复代理询问的标题
    saveEditAgentParams: {},
    radioChecked: 1,
}
export class AgentStore {
    layout = new RouteLayout.Store({ route: '/agent/mineAgentSet', });//代理列表的快捷搜索页
    searchPage_layout = new RouteLayout.Store({ route: '/agent/mineAgentSet', id: "agentSearch" });
    searchValue = "";


    //4个tab页
    @observable initDatas = { ...initDatas };
    //新建代理 新建模板 编辑模板 从模板导入并新建代理 这几个页面
    @observable addAgent = { ...initAddAgent };
    //index下的store
    @observable isShowMask = false;
    //模板管理 从模板中导入 两个页面的store
    @observable tempManagement = { ...initTempManagement };
    //存为模板
    @observable SaveAsTem = { ...initSaveAsTem };
    //高级搜索
    @observable advancedItem = { ...initAdvancedItem };
    //编辑代理
    @observable editAgent = { ...initEditAgent };
    //从模板导入
    @observable importFromTem = { ...initInportFromTem };
    //下拉刷新
    initAddAgentDom = (params) => {
        let symbol = this.addAgent.symbol;
        let templateid = this.addAgent.templateid;
        this.addAgent = initAddAgent;
        this.addAgent.symbol = symbol;
        this.addAgent.templateid = templateid;
        if (symbol) {
            this.getAddAgentInfo(params);
        }
    }

    @action
    setMobxStore = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this[key] = state[key]
        })
    }
    @action
    setInitDatas = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.initDatas[key] = state[key]
        })
    }
    @action
    setImportFromTemData = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.importFromTem[key] = state[key]
        })
    }

    setResultDatasState = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.addAgent[key] = state[key]
        })
    }

    @action("修改tempManagement的数据")
    setTempMDatas = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.tempManagement[key] = state[key]
        })
    }
    setHasRequiredItem = (val) => {
        this.editAgent.hasRequiredItem = val;
    }
    setSwitchOffAllItem = (val) => {
        this.editAgent.switchOffAllItem = val;
    }

    @action("切换tab后要重新走接口")
    changeTab = (tab) => {
        switch (tab) {
            case 0:
                this.initListData(0);
                break;
            case 1:
                this.initListData(1);
                break;
            case 2:
                this.initListData(2);
                break;
            case 3:
                this.initListData(3);
                break;
            default:
        }
        this.initDatas.isShowCheck = false;
    }

    initListData = (type) => {
        let params = {
            agented: 0, agentFlag: 0, ismobile: 1
        }
        let page = "/agent/mineAgentSet";
        if (type === 0) {
            params = { agented: 0, agentFlag: 0, ismobile: 1 }
            page = "/agent/mineAgentSet";
            this.initDatas.listViewPage_listsotre14 = new ListViewPage.Store({ route: page, id: page });
        } else if (type === 1) {
            params = { agented: 1, agentFlag: 1, ismobile: 1 }
            page = "/agent/hadAgented";
            this.initDatas.listViewPage_listsotre23 = new ListViewPage.Store({ route: page, id: page });
        } else if (type === 2) {
            params = { agented: 1, agentFlag: 0, ismobile: 1 }
            page = "/agent/toOthersAgent";
            this.initDatas.listViewPage_listsotre23 = new ListViewPage.Store({ route: page, id: page });
        } else if (type === 3) {
            params = { agented: 0, agentFlag: 1, ismobile: 1 }
            page = "/agent/all";
            this.initDatas.listViewPage_listsotre14 = new ListViewPage.Store({ route: page, id: page });
        }
        this.setInitDatas({
            showCheck: false,
            selectedRowKeys: [],
            isSelectedAll: false,
            search: new SearchAdvanced.Store({ route: page }),
            // listViewPage_listsotre: new ListViewPage.Store({ route: page, id: page }),
            searchValue: "",
            listParams: params,
            nowPath: page,
            searchPage: new SearchPage.Store({ route: page, id: "agentSearch" }),
            layout_batchEdit: new RouteLayout.Store({ route: page, id: "batchEdit" }),
            searchParams: {},
            isAdVancedHasData: false,
            defaultAdvancedValue: {},
        });
        this.layout = new RouteLayout.Store({ route: page, id: "advanceSearch" });
        this.searchPage_layout = new RouteLayout.Store({ route: page, id: "searchPage" });
        this.searchValue = "";
        this.tempManagement.searchParams = {};
        this.tempManagement.searchValue = "";
        this.getAgentDatas(params);
        this.getSearchCondition(params)
    }

    onSearchSubmit = (e) => {
        /**
      * 1获取输入的值
      * 2请求接口的时候拿这个值来请求（没有大小写转换的）
      * 3把这个值撞到list的sotre中
      */
        let fu2;
        if (toJS(e).name) {
            fu2 = toJS(e).name;
        } else {
            fu2 = e;
        }
        fu2 = fu2.trim();
        this.searchValue = fu2;

        //保存搜索历史
        let ssStr = "";
        if (this.initDatas.nowPath === "/agent/mineAgentSet" || this.initDatas.nowPath === "/agent") {
            ssStr = "mineAgentSet";
        } else if (this.initDatas.nowPath === "/agent/all") {
            ssStr = "all";
        } else if (this.initDatas.nowPath === "/agent/hadAgented") {
            ssStr = "hadAgented";
            if (fu2 === "") {
                this.initDatas.isAdVancedHasData = false;
            } else {
                this.initDatas.isAdVancedHasData = true;
            }
        } else if (this.initDatas.nowPath === "/agent/toOthersAgent") {
            ssStr = "toOthersAgent";
            if (fu2 === "") {
                this.initDatas.isAdVancedHasData = false;
            } else {
                this.initDatas.isAdVancedHasData = true;
            }
        } else if (this.initDatas.nowPath === "/agent/importFromTem/searchPage" || this.initDatas.nowPath === "/agent/importFromTem") {
            ssStr = "importFromTem";
            if (fu2 === "") {
                this.initDatas.isAdVancedHasData = false;
            } else {
                this.initDatas.isAdVancedHasData = true;
            }
        } else if (this.initDatas.nowPath === "/agent/temManagement/searchPage" || this.initDatas.nowPath === "/agent/temManagement") {
            ssStr = "temManagement";
            if (fu2 === "") {
                this.initDatas.isAdVancedHasData = false;
            } else {
                this.initDatas.isAdVancedHasData = true;
            }
        }
        if (fu2 !== "") {
            this.setLocalStorage(ssStr, fu2)
        }
        /***请求接口 */
        if (this.initDatas.nowPath === "/agent/hadAgented" || this.initDatas.nowPath === "/agent/toOthersAgent") {
            this.initDatas.searchParams = { requestname: fu2, ...this.initDatas.listParams, ismobile: 1 };
            this.getAgentDatas({ requestname: fu2, ...this.initDatas.listParams, ismobile: 1 });
        } else if (this.initDatas.nowPath === "/agent/mineAgentSet" || this.initDatas.nowPath === "/agent/all") {
            this.initDatas.searchParams = { searchValue: fu2, ...this.initDatas.listParams, ismobile: 1 };
            this.getAgentDatas({ searchValue: fu2, ...this.initDatas.listParams, ismobile: 1 });
        } else if (this.initDatas.nowPath === "/agent/importFromTem/searchPage" || this.initDatas.nowPath === "/agent/importFromTem") {
            let params = {
                "name": fu2,
            }
            this.importFromTem.searchParams = params;
            this.agentTemplate(params);
        } else if (this.initDatas.nowPath === "/agent/temManagement/searchPage" || this.initDatas.nowPath === "/agent/temManagement") {
            let params = {
                "name": fu2
            }
            this.tempManagement.searchParams = params;
            this.agentTemplateList(params);
        }
    }

    setLocalStorage = (ssStr, fu2) => {
        let arr = [];
        if (Tools.ss.getJSONObj(ssStr)) {
            arr = Tools.ss.getJSONObj(ssStr);
        }
        if (arr.length <= 0) {
            if (fu2.replace(/(^\s*)|(\s*$)/g, "") !== "") {
                arr.push({ name: fu2, key: "0" })
            }
        } else {
            let index = -1;
            let flag = false;//输入的e是否已在记录中
            arr.map(item => {
                if (item.name.trim() === fu2) {
                    flag = true;
                    index = parseInt(item.key, 10);
                }
                return index;
            })
            if (flag) {//已在记录中
                arr.splice(index, 1);
                arr.slice(0, index).forEach(item => {
                    item.key = (parseInt(item.key, 10) + 1).toString();
                })
                if (fu2.replace(/(^\s*)|(\s*$)/g, "") !== "") {
                    arr.unshift({ name: fu2, key: "0" });
                }
            } else {//不再记录中
                arr.forEach(item => {
                    item.key = (parseInt(item.key, 10) + 1).toString();
                })
                if (fu2.replace(/(^\s*)|(\s*$)/g, "") !== "") {
                    arr.unshift({ name: fu2, key: "0" });
                }
                if (arr.length > 5) {
                    arr.pop();
                }
            }
        }
        Tools.ss.set(ssStr, arr);
    }

    @action("改变addAgent中的值")
    setAddAgent = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.addAgent[key] = state[key]
        })
    }

    @action("改变editAgent中的值")
    setEditAgent = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.editAgent[key] = state[key]
        })
    }

    @action("获取当前新建代理数据")
    getAddAgentInfo = (params) => {
        API.getAddAgentInfo(params).then(datas => {
            if (datas) {
                const { fields = {}, formValue = {} } = datas;
                datas.fields = this.changeLabel(datas.fields);
                for (let key in datas.fields) {
                    if (key === "bagentuid" || key === "agentuid" || key === "rangetype") {
                        datas.fields[key].browserConditionParam.viewAttr = 3;
                    }
                    if (key === "userSelect") {
                        this.addAgent.selectIdentatity_data = datas.fields[key].options;
                    }
                }
                this.addAgent.datas = datas;
                let arr = [];
                for (let key in fields) {
                    arr.push(fields[key])
                }
                this.addAgent.form.initForm(arr, '/agent/addAgent')
                if (datas.hasOwnProperty('formValue') && JSON.stringify(datas.formValue) !== "{}") {
                    if (formValue.bagentuid) {
                        if (formValue.bagentuid.value) {
                            formValue.bagentuid = {//浏览按钮类型更新无效
                                value: [{ id: formValue.bagentuid.value, name: formValue.bagentuid.valueSpan }]
                            }
                            this.addAgent.default_bagentuid = formValue.bagentuid.value[0].id;
                        } else {
                            formValue.bagentuid = { value: [] };
                        }
                    } else {
                        formValue.bagentuid = { value: [] };
                    }
                    if (formValue.agentuid) {
                        if (formValue.agentuid.value) {
                            formValue.agentuid = {//浏览按钮类型更新无效
                                value: [{ id: formValue.agentuid.value, name: formValue.agentuid.valueSpan }]
                            }
                        } else {
                            formValue.agentuid = { value: [] };
                        }
                    } else {
                        formValue.agentuid = { value: [] };
                    }
                    if (fields.userSelect) {//如果有多身份选择
                        if (formValue.userSelect) {
                            if (formValue.userSelect.value) {
                                this.addAgent.selectIdentatity_data.map(item => {
                                    if (item.key === formValue.userSelect.value) {
                                        this.addAgent.bagentuid_identatity = item;
                                    }
                                })
                            }
                        } else {
                            this.addAgent.bagentuid_identatity = { key: "all", showname: getLabel(500409, "全部身份") };
                        }
                    } 
                    if (formValue.rangetype) {
                        formValue.rangetype = {//浏览按钮类型更新无效
                            value: formValue.rangetype.valueObj
                        }
                    }
                    if (formValue.hasOwnProperty("isProxyDeal") || formValue.hasOwnProperty("isPendThing")
                        || formValue.hasOwnProperty("isCreateAgenter") || formValue.hasOwnProperty("isSysCreateAgenter")) {
                        this.changeItemToBool(formValue);
                    } else {
                        formValue.isProxyDeal = { value: true };
                        formValue.isPendThing = { value: false };
                        formValue.isCreateAgenter = { value: false };
                        formValue.isSysCreateAgenter = { value: false };
                    }
                    this.addAgent.form.updateFields({ ...datas.formValue });
                } else {
                    this.addAgent.form.updateFields({
                        isProxyDeal: { value: true },
                        isPendThing: { value: false },
                        isCreateAgenter: { value: false },
                        isSysCreateAgenter: { value: false }
                    });
                }
            }
        })
    }

    changeValue(val) {
        if (val === "0") {
            val = false;
        } else if (val === "1") {
            val = true;
        }
        return val;
    }
    getValue(val, bool) {
        if (val) {
            val.value = this.changeValue(val.value);
        } else {
            val = { value: bool };
        }
        return val;
    }

    changeLabel(fields) {
        for (let key in fields) {
            switch (key) {
                case "templatename": fields[key].label = getLabel(28050, "模板名称"); break;
                case "bagentuid": fields[key].label = getLabel(17565, "被代理人"); break;
                case "agentuid": fields[key].label = getLabel(17566, "代理人"); fields[key].viewAttr = 3; break;
                case "beginDate": fields[key].label = getLabel(740, "开始日期"); break;
                case "beginTime": fields[key].label = getLabel(500371, "开始时间"); break;
                case "endDate": fields[key].label = getLabel(741, "结束日期"); break;
                case "endTime": fields[key].label = getLabel(500372, "结束时间"); break;
                case "isCreateAgenter": fields[key].label = getLabel(383538, "代理流程创建"); break;
                case "isSysCreateAgenter": fields[key].label = getLabel(515615, "代理创建子流程"); break;
                case "isPendThing": fields[key].label = getLabel(33250, "代理已有待办事宜"); break;
                case "isProxyDeal": fields[key].label = getLabel(82585, "代理流程处理"); break;
                case "agentrange": fields[key].label = getLabel(383507, "代理流程范围"); break;
                case "rangetype": fields[key].label = getLabel(388572, "请选择流程"); break;
                case "workflowid": fields[key].label = getLabel(34067, "流程路径"); break;
                default:
            }
        }
        return fields;
    }

    @action("编辑代理")
    getAgentDetail = (params) => {

        API.getAgentDetail({ ...params, ismobile: 1 }).then(results => {
            if (JSON.stringify(results) !== "{}") {
                let { datas = [], fields = {}, formValue, conditioninfo = [], agentid = "" } = results;
                this.editAgent.agentid = agentid;
                datas.map(item => {
                    item.agentuidSpan = getLabel(17566, "代理人") + "：";
                    item.isCreateAgenterSpan = getLabel(383538, "代理流程创建") + "：";
                    item.isSysCreateAgenterSpan = getLabel(515615, "代理创建子流程") + ":";
                    item.isPendThingSpan = getLabel(33250, "代理已有待办事宜") + "：";
                    item.isProxyDealSpan = getLabel(82585, "代理流程处理") + "：";
                    item.conditioncnSpan = getLabel(519446, "代理流程处理条件") + "：";
                    item.batchSpan = getLabel(17892, "批次") + "：";
                    this.changeItem(item);
                    return item;
                })
                this.editAgent.datas = datas;
                fields = this.changeLabel(fields);
                this.editAgent.fields = fields;
                if (conditioninfo.length > 0) {
                    conditioninfo[0].items.map(item => {
                        if (item.domkey[0] === "agentuid") {
                            item.viewAttr = 3;
                            item.browserConditionParam.viewAttr = 3;

                        }
                    })
                    this.editAgent.conditioninfo = conditioninfo;
                    this.editAgent.detailForm.initForm(conditioninfo, "/agent/editDetails")
                }
                let arr = [];
                for (let key in fields) {
                    if (key === "bagentuid") {
                        fields[key].viewAttr = 3;
                    }
                    arr.push(fields[key]);
                }
                this.editAgent.form.initForm(arr, "/agent/editAgent")
                if (formValue) {
                    if (formValue.bagentuid) {
                        if (formValue.bagentuid.value) {
                            formValue.bagentuid = { value: [{ id: formValue.bagentuid.value, name: formValue.bagentuid.valueSpan }] }
                        } else {
                            formValue.bagentuid = { value: [] }
                        }
                    } else {
                        formValue.bagentuid = { value: [] }
                    }
                    if (formValue.workflowid) {
                        if (formValue.workflowid.value) {
                            formValue.workflowid = { value: [{ id: formValue.workflowid.value, name: formValue.workflowid.valueSpan }] }
                        } else {
                            formValue.workflowid = { value: [] }
                        }
                    } else {
                        formValue.workflowid = { value: [] }
                    }
                    this.getTimeUtil(formValue, "beginDate");
                    this.getTimeUtil(formValue, "beginTime");
                    this.getTimeUtil(formValue, "endDate");
                    this.getTimeUtil(formValue, "endTime");
                }
                this.editAgent.form.updateFields(formValue);
            }
        })
    }


    getTimeUtil = (formValue, key) => {
        if (formValue[key]) {
            if (formValue[key].value == "") {
                this.editAgent[key] = null;
            } else {
                this.editAgent[key] = formValue[key].value
            }
        }
    }
    //判断当前打开的列有无上下列
    checkHasP_N = (id) => {
        let newDatas = toJS(this.editAgent.datas);
        for (let i = 0; i < newDatas.length; i++) {
            if (id === newDatas[i].id) {
                if (i - 1 < 0) {
                    this.editAgent.isHasPre = false;
                } else {
                    this.editAgent.isHasPre = true;
                }
                if (i + 1 >= newDatas.length) {
                    this.editAgent.isHasNext = false;
                } else {
                    this.editAgent.isHasNext = true;
                }
            }
        }
    }

    // @action("上一行下一行")
    moveLine = (type) => {
        let copydatas = toJS(this.editAgent.datas);
        let nowId = this.editAgent.detailDataId;
        if (type) {//上一行
            if (this.editAgent.isHasPre) {
                for (let i = 0; i < copydatas.length; i++) {
                    if (copydatas[i].id === nowId) {
                        this.editAgent.detailDataId = copydatas[i - 1].id;
                        copydatas.map(item => {
                            if (item.id === this.editAgent.detailDataId) {
                                if (item.agentuid) {
                                    item.agentuid = { value: [{ id: item.agentuid, name: item.agentuidspan }] }
                                } else {
                                    item.agentuid = { value: [] }
                                }
                                this.changeItemToFormValue(item);
                                this.editAgent.detailForm.updateFields(item);
                            }
                            return item;
                        })
                    }
                }
            } else {
                Bubble.remind(getLabel(500374,'没有上一行了！'), 2);
            }
        } else {//下一行
            if (this.editAgent.isHasNext) {
                for (let i = 0; i < copydatas.length; i++) {
                    if (copydatas[i].id === nowId) {
                        this.editAgent.detailDataId = copydatas[i + 1].id;
                        copydatas.map(item => {
                            if (item.id === this.editAgent.detailDataId) {
                                if (item.agentuid) {
                                    item.agentuid = { value: [{ id: item.agentuid, name: item.agentuidspan }] }
                                } else {
                                    item.agentuid = { value: [] }
                                }
                                this.changeItemToFormValue(item);
                                this.editAgent.detailForm.updateFields(item);
                            }
                            return item;
                        })
                    }
                }
            } else {
                Bubble.remind(getLabel(500373,'没有下一行了！'), 2);
            }
        }
        this.checkHasP_N(this.editAgent.detailDataId);
    }

    //添加一行
    addAgenterMsg = () => {
        let copydatas = [...toJS(this.editAgent.datas)];

        let lastid = "0";
        if (copydatas.length > 0) {
            lastid = copydatas[copydatas.length - 1].id;
        }
        if (lastid.includes("_")) {
            lastid = lastid.split("_")[1];
        }
        let params = {
            agentbatch: "0.00",
            batchSpan: getLabel(17892, "批次") + "：",
            agentuid: "",
            agentuidSpan: getLabel(17566, "代理人") + "：",
            agentuidspan: "",
            conditioncn: "",
            conditionkeyid: "",
            conditionss: "",
            conditioncnSpan: getLabel(519446, "代理流程处理条件") + "：",
            id: "new_" + (parseInt(lastid, 10) + 1).toString(),
            isCreateAgenter: getLabel(161, "否"),
            isCreateAgenterSpan: getLabel(383538, "代理流程创建") + "：",
            isSysCreateAgenter: getLabel(161, "否"),
            isSysCreateAgenterSpan: getLabel(515615, "代理创建子流程") + "：",
            isPendThing: getLabel(161, "否"),
            isPendThingSpan: getLabel(33250, "代理已有待办事宜") + "：",
            isProxyDeal: getLabel(163, "是"),
            isProxyDealSpan: getLabel(82585, "代理流程处理") + "：",
            // ruleRelationship: "移动端不支持设置条件",
        }
        copydatas.push(params);
        this.editAgent.datas.replace(copydatas);
        // form也要变
        let newform = new Form.Store();
        newform.initForm(this.editAgent.conditioninfo, "/agent/editDetails")
        if (params.agentuid) {
            params.agentuid = { value: [{ id: params.agentuid, name: params.agentuidspan }] }
        } else {
            params.agentuid = { value: [] }
        }
        this.changeItemToFormValue(params);
        newform.updateFields(params)
        this.editAgent.detailForm = newform;
        this.editAgent.isHasPre = true;
        this.editAgent.isHasNext = false;
        this.editAgent.detailDataId = params.id;
        this.editAgent.isSelectedAll = false;
    }

    //删除一行或多行
    deleteLine = (ids, history, isDetailDelete) => {
        if (ids === "" || ids.length === 0) {
            Bubble.warning(getLabel(386176,'请选择需要删除的记录'), 2);
        } else {
            Modal.alert(getLabel(15097,'确定要删除吗？'), "", [
                { text: getLabel(201,'取消'), onPress: () => console && console.log('cancel') },
                {
                    text: getLabel(826,'确定'), onPress: () => {
                        if (typeof ids === "string") {//删除一行
                            this.deleteALien(ids, history, isDetailDelete);
                        } else {//删除多行 ids是个数组
                            ids.map(id => {
                                this.deleteALien(id, history, isDetailDelete);
                                return id;
                            })
                        }
                    }
                },
            ])
        }



    }

    //删除一行
    deleteALien = (id, history, isDetailDelete) => {
        let copydatas = cloneDeep(toJS(this.editAgent.datas));
        for (let i = 0; i < copydatas.length; i++) {
            if (copydatas[i].id === id) {
                // 这是有用的代码，但是我的测试朋友让我不要这么干，我很郁闷
                // let item = { id: "0" };
                // if ((i === this.editAgent.datas.length - 1) && i === 0) {//无下一列且无上一列
                //     this.editAgent.detailDataId = "0";
                //     this.editAgent.isHasNext = false;
                //     this.editAgent.isHasPre = false;
                //     this.editAgent.detailForm.initForm(this.editAgent.conditioninfo, "/agent/editDetails")
                //     if (isDetailDelete) {
                //         history.push("/agent/editAgent");//没有数据了就返回上一页面
                //     }
                // } else {
                //     if (i === this.editAgent.datas.length - 1) {//无下一列且有上一列
                //         this.editAgent.detailDataId = copydatas[i - 1].id;
                //         item = toJS(this.editAgent.datas)[i - 1];
                //     } else { //有下一列
                //         this.editAgent.detailDataId = copydatas[i + 1].id;
                //         item = toJS(this.editAgent.datas)[i + 1];
                //     }
                //     this.checkHasP_N(item.id);
                //     let newform = new Form.Store();
                //     newform.initForm(this.editAgent.conditioninfo, "/agent/editDetails")
                //     item.agentuid = { value: [{ id: item.agentuid, name: item.agentuidspan }] }
                //     this.changeItemToFormValue(item);
                //     newform.updateFields(item)
                //     this.editAgent.detailForm = newform;
                // }
                copydatas.splice(i, 1);
                history.push("/agent/editAgent")
            }
        }
        this.editAgent.datas = copydatas;
        this.editAgent.isSelectedAll = false;
        this.editAgent.selectedRowKeys = [];
    }

    @action("保存设置好的新建代理")
    addAgentSave = (params, Fun) => {
        this.addAgent.isShowLoading = true;
        API.addAgentSave(params).then(datas => {
            const { agentresult = {} } = datas;
            if (agentresult === 'success') {
                Bubble.success(getLabel(18758,'保存成功'), 2);
                this.addAgent.isShowLoading = false;
                if (Fun) {
                    if (typeof Fun === 'function') {
                        Fun();
                    }
                }
            }
        })
    }
    //原始数据改造
    changeItem(item) {
        if (item.isCreateAgenter === "0" || item.isCreateAgenter === 0) {
            item.isCreateAgenter = getLabel(161, "否");
        } else {
            item.isCreateAgenter = getLabel(163, "是");
        }
        if (item.isSysCreateAgenter == 0 ) {
            item.isSysCreateAgenter = getLabel(161, "否");
        } else {
            item.isSysCreateAgenter = getLabel(163, "是");
        }
        if (item.isPendThing === "0" || item.isPendThing === 0) {
            item.isPendThing = getLabel(161, "否");
        } else {
            item.isPendThing = getLabel(163, "是");
        }
        if (item.isProxyDeal === "0" || item.isProxyDeal === 0) {
            item.isProxyDeal = getLabel(161, "否");
        } else {
            item.isProxyDeal = getLabel(163, "是");
        }
        return item;
    }

    //用来显示在列表
    changeBoolItem(item) {
        if (item.isCreateAgenter === false) {
            item.isCreateAgenter = getLabel(161, "否");
        } else {
            item.isCreateAgenter = getLabel(163, "是");
        }
        if (item.isSysCreateAgenter === false) {
            item.isSysCreateAgenter = getLabel(161, "否");
        } else {
            item.isSysCreateAgenter = getLabel(163, "是");
        }
        if (item.isPendThing === false) {
            item.isPendThing = getLabel(161, "否");
        } else {
            item.isPendThing = getLabel(163, "是");
        }
        if (item.isProxyDeal === false) {
            item.isProxyDeal = getLabel(161, "否");
        } else {
            item.isProxyDeal = getLabel(163, "是");
        }
        // if (item.ruleRelationship === "") {
        //     item.ruleRelationship = "移动端不支持设置条件";
        // }
        return item;
    }

    changeItemToBool(item) {
        if (item.isCreateAgenter.value) {
            if (item.isCreateAgenter.value === "0") {
                item.isCreateAgenter = { value: false };
            } else {
                item.isCreateAgenter = { value: true };
            }
        } else {
            if (item.isCreateAgenter === "0") {
                item.isCreateAgenter = { value: false };
            } else {
                item.isCreateAgenter = { value: true };
            }
        }

        if (item.isSysCreateAgenter.value) {
            if (item.isSysCreateAgenter.value === "0") {
                item.isSysCreateAgenter = { value: false };
            } else {
                item.isSysCreateAgenter = { value: true };
            }
        } else {
            if (item.isSysCreateAgenter === "0") {
                item.isSysCreateAgenter = { value: false };
            } else {
                item.isSysCreateAgenter = { value: true };
            }
        }
        if (item.isPendThing.value) {
            if (item.isPendThing.value === "0") {
                item.isPendThing = { value: false };
            } else {
                item.isPendThing = { value: true };
            }
        } else {
            if (item.isPendThing === "0") {
                item.isPendThing = { value: false };
            } else {
                item.isPendThing = { value: true };
            }
        }

        if (item.isProxyDeal.value) {
            if (item.isProxyDeal.value === "0") {
                item.isProxyDeal = { value: false };
            } else {
                item.isProxyDeal = { value: true };
            }
        } else {
            if (item.isProxyDeal === "0") {
                item.isProxyDeal = { value: false };
            } else {
                item.isProxyDeal = { value: true };
            }
        }
        return item;
    }
    //能用来初始化form的
    changeItemToFormValue(item) {
        if (item.isCreateAgenter === getLabel(161, "否")) {
            // if (item.isCreateAgenter === "否" || item.isCreateAgenter === "") {
            item.isCreateAgenter = { value: false };
        } else {
            item.isCreateAgenter = { value: true };
        }
        if (item.isSysCreateAgenter === getLabel(161, "否")) {
            item.isSysCreateAgenter = { value: false };
        } else {
            item.isSysCreateAgenter = { value: true };
        }
        if (item.isPendThing === getLabel(161, "否")) {
            // if (item.isPendThing === "否" || item.isPendThing === "") {
            item.isPendThing = { value: false };
        } else {
            item.isPendThing = { value: true };
        }
        if (item.isProxyDeal === getLabel(161, "否")) {
            // if (item.isProxyDeal === "否" || item.isProxyDeal === "") {
            item.isProxyDeal = { value: false };
        } else {
            item.isProxyDeal = { value: true };
        }
        item.conditioncn = { value: item.conditioncn };
        item.agentbatch = { value: item.agentbatch };
        return item;
    }
    //能用来做保存的
    changeItemToSave(item) {
        if (item.isCreateAgenter === getLabel(161, "否")) {
            item.isCreateAgenter = "0";
        } else {
            item.isCreateAgenter = "1";
        }
        if (item.isSysCreateAgenter === getLabel(161, "否")) {
            item.isSysCreateAgenter = "0";
        } else {
            item.isSysCreateAgenter = "1";
        }
        if (item.isPendThing === getLabel(161, "否")) {
            item.isPendThing = "0";
        } else {
            item.isPendThing = "1";
        }
        if (item.isProxyDeal === getLabel(161, "否")) {
            item.isProxyDeal = "0";
        } else {
            item.isProxyDeal = "1";
        }
        // item.conditioncn = "";
        return item;
    }

    changeItemtoNUM(item) {
        if (item.isCreateAgenter === false || item.isCreateAgenter === "0" || item.isCreateAgenter === 0) {
            item.isCreateAgenter = "0";
        } else {
            item.isCreateAgenter = "1";
        }
        if (item.isSysCreateAgenter === false || item.isSysCreateAgenter === "0" || item.isSysCreateAgenter === 0) {
            item.isSysCreateAgenter = "0";
        } else {
            item.isSysCreateAgenter = "1";
        }
        if (item.isPendThing === false || item.isPendThing === "0" || item.isPendThing === 0) {
            item.isPendThing = "0";
        } else {
            item.isPendThing = "1";
        }
        if (item.isProxyDeal === false || item.isProxyDeal === "0" || item.isProxyDeal === 0) {
            item.isProxyDeal = "0";
        } else {
            item.isProxyDeal = "1";
        }
        return item;
    }


    formValidation = (params = {}) => {//保存之前的表单验证【新建模板，编辑模板，新建代理】   编辑代理的保存时另一中形式的验证
        let flag = true;
        let beginDT = Date.parse(new Date(params.beginDate + " " + (params.beginTime ? params.beginTime : "00:00") + ":00"));
        let endDT = Date.parse(new Date(params.endDate + " " + (params.endTime ? params.endTime : "23:59") + ":00"));
        let str = "";
        if (params.hasOwnProperty("userSelect")) {
            str = params.userSelect.substr(("single_").length);
        }
        if (params.hasOwnProperty("templatename") && params.templatename === "" && (this.addAgent.symbol !== "addAgent")) {
            Bubble.warning(getLabel(18510,'请输入模板名称'), 2);
            flag = false;
        } else if (params.hasOwnProperty("templatename") && params.templatename.length > 200) {
            Bubble.warning(getLabel(391146,"模板名称长度不能超过200字符"), 2)
            flag = false;
        } else if (params.agentuid === "") {
            Bubble.warning(getLabel(500288,'请选择代理人'), 2);
            flag = false;
        } else if (params.bagentuid === "") {
            Bubble.warning(getLabel(500289,'请选择被代理人'), 2);
            flag = false;
        } else if (params.hasOwnProperty("userSelect") && (str === params.agentuid)) {
            Bubble.warning(getLabel(391144,'被代理人、代理人不能相同'), 2);
            flag = false;
        } else if (params.agentuid == params.bagentuid) {
            Bubble.warning(getLabel(391144, '被代理人、代理人不能相同'), 2);
            flag = false;
        } else if (params.beginTime && !params.beginDate) {
            Bubble.warning(getLabel(127684,'设置开始时间必须设置开始日期'), 2);
            flag = false;
        } else if (params.endTime && !params.endDate) {
            Bubble.warning(getLabel(127685,'设置结束时间必须设置结束日期'), 2);
            flag = false;
        } else if (endDT <= beginDT) {
            Bubble.warning(getLabel(127683,"结束时间不能小于等于开始时间"), 2);
            flag = false;
        } else if (params.isProxyDeal === "0" && params.isCreateAgenter === "0") {
            Bubble.warning(getLabel(391143,'【代理流程创建】和【代理流程处理】至少启用一项'), 2);
            flag = false;
        } else if (params.agentrange === "1" && params.rangetype === "") {
            Bubble.warning(getLabel(388572, "请选择流程"), 2);
            flag = false;
        } else {
            flag = true;
        }
        return flag;
    }

    @action("存为模板")
    saveAgentTemplate = (params, Fun) => {
        this.tempManagement.isShowLoading = true;
        API.saveAgentTemplate(params).then(datas => {
            const { api_status = {} } = datas;
            if (api_status === true) {
                Bubble.success(getLabel(83551,'保存成功!'), 2);
                if (typeof Fun === 'function') {
                    this.tempManagement.isShowLoading = false;
                    Fun();
                }
            }
        })
    }


    @action("删除模板")
    deleteTemplate = (params) => {
        this.tempManagement.isShowLoading = true;
        API.deleteTemplate(params).then(datas => {
            const { api_status = '' } = datas
            if (api_status) {
                Bubble.success(getLabel(83472,'删除成功！'), 2);
                this.tempManagement.isShowCheck = false;
                this.tempManagement.isShowLoading = false;
                this.initDatas.isAdVancedHasData = false;
                this.searchValue = "";
                this.agentTemplateList();
            }
        })
    }

    @action("修改store中的属性--【公共方法】")
    setState = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this[key] = state[key]
        })
    }

    @action("获取数据")//可删除
    getAgentDatas = (params) => {
        API.getAgentDatas(params).then(datas => {
            const { sessionkey = "" } = datas;
            this.initDatas.sessionkey = sessionkey;
            if ((params.agented === 0 && params.agentFlag === 0) || (params.agented === 0 && params.agentFlag === 1)) {
                this.initDatas.listViewPage_listsotre14 = new ListViewPage.Store({ route: this.initDatas.nowPath, id: this.initDatas.nowPath });
                this.initDatas.listViewPage_listsotre14.getData({ dataKey: sessionkey });
            } else if ((params.agented === 1 && params.agentFlag === 1) || (params.agented === 1 && params.agentFlag === 0)) {
                this.initDatas.listViewPage_listsotre23 = new ListViewPage.Store({ route: this.initDatas.nowPath, id: this.initDatas.nowPath });
                this.initDatas.listViewPage_listsotre23.getData({ dataKey: sessionkey });
            }
            this.initDatas.isSelectedAll = false;
            this.initDatas.selectedRowKeys = [];
        })
    }


    @action("修改AdvancedItem中的数据")
    setAdvancedItem = (state = {}) => {
        const keys = Object.keys(state);
        keys.forEach(key => {
            this.advancedItem[key] = state[key]
        })
    }


    getPageTitle = (pathName, symbol) => {
        let title = "";
        let showCloseButton = false;
        if (pathName === "/agent/mineAgentSet" || pathName === "/agent" || pathName === "/agent/all" || pathName === "/agent/hadAgented" || pathName === "/agent/toOthersAgent") {
            title = getLabel(17723,"流程代理");
            showCloseButton = true;
        } else if (pathName.includes("/agent/temManagement")) {
            title = getLabel(20823,"模板管理");
        } else if (pathName.includes("/agent/addAgent")) {
            if (symbol === "addAgent") {
                title = getLabel(33242,"新建代理");
            } else if (symbol === "addTemplate") {
                title = getLabel(16388,"新建模板");
            } else if (symbol === "editTemplate") {
                title = getLabel(28052,"编辑模板");
            } else if (symbol === "importTemplate") {
                title = getLabel(500290,"从模板导入并新建代理");
            }
        } else if (pathName.includes("/agent/importFromTem")) {
            title = getLabel(32385,"从模板导入");
        } else if (pathName === "/agent/addAgent/saveAsTemplate") {
            title = getLabel(18418,"存为模板");
        } else if (pathName.includes("/agent/mineAgentSet/advanceSearch") || pathName.includes("/agent/hadAgented/advanceSearch") || pathName.includes("/agent/toOthersAgent/advanceSearch") || pathName.includes("/agent/all/advanceSearch")) {
            title = getLabel(347,"高级搜索");
        } else if (pathName === "/agent/mineAgentSet/batchEdit") {
            title = getLabel(383518,"批量编辑");
        } else if (pathName === "/agent/editAgent") {
            title = getLabel(500291,"编辑代理");
        } else if (pathName.includes("/agent/editDetails")) {
            title = getLabel(500293,"添加详细信息");
        }
        EmSDK.controlEmTopNav({ title: title, showCloseButton: showCloseButton })
    }

    getPageTitleSub = (pathName, symbol) => {
        let title = "";
        if (pathName.includes("/agent/addAgent")) {
            if (symbol === "addAgent") {
                title = getLabel(33242, "新建代理");
            } else if (symbol === "addTemplate") {
                title = getLabel(16388, "新建模板");
            } else if (symbol === "editTemplate") {
                title = getLabel(28052, "编辑模板");
            } else if (symbol === "importTemplate") {
                title = getLabel(500290, "从模板导入并新建代理");
            }
        }
        return title;
    }

    @action("高级搜索")
    getSearchCondition = (params) => {
        API.getSearchCondition(params).then(datas => {
            const { formValue = {} } = datas;
            let myCondition = {}
            if (datas.hasOwnProperty("condition")) {
                myCondition = datas.condition;
            } else {
                myCondition = datas.conditioninfo;
            }
            if (JSON.stringify(myCondition) !== "{}") {
                let condition_ = {};
                if (this.initDatas.nowPath === '/agent/mineAgentSet' || this.initDatas.nowPath === '/agent/all') {
                    condition_ = myCondition;
                } else if (this.initDatas.nowPath === '/agent/hadAgented' || this.initDatas.nowPath === '/agent/toOthersAgent') {
                    if (myCondition.length > 0) {
                        condition_ = myCondition[0].items;
                    } else {
                        condition_ = [];
                    }
                }
                this.advancedItem.form.initForm(condition_, this.initDatas.nowPath + '/advanceSearch');
                if (formValue.bagentuid) {
                    if (formValue.bagentuid.value) {
                        formValue.bagentuid = { value: [{ id: formValue.bagentuid.value, name: formValue.bagentuid.valueSpan }] }
                    } else {
                        formValue.bagentuid = { value: [] }
                    }
                }

                this.advancedItem.formValue = formValue;
                this.advancedItem.form.updateFields(formValue);
                // this.initDatas.defaultAdvancedValue = this.advancedItem.form.formParams;
                this.advancedItem.conditioninfo = condition_;
            }
        })
    }

    @action
    getBatchEditInfo = (params) => {
        API.getBatchEditInfo(params).then(datas => {
            if (datas) {
                datas.fields = this.changeLabel(datas.fields);
                this.initDatas.batchEditDatas = datas;
            }
        })
    }
    @action
    verifyAgentOverlap = (params, callback) => {
        if (params.method) {
            if (params.method === "editBatch") {
                this.initDatas.batch_isShowLoading = true;
            }
        }
        API.verifyAgentOverlap(params).then(datas => {
            if (datas) {
                if (typeof callback === "function") {
                    callback(datas);
                }
            }
        })
    }

    @action
    saveBatchEditInfo = (params, callback) => {

        API.saveBatchEditInfo(params).then(datas => {
            if (datas) {
                this.initDatas.batch_isShowLoading = false;
                if (typeof callback === 'function') {
                    callback(datas);
                    if (JSON.stringify(this.initDatas.searchParams) !== "{}") {
                        this.getAgentDatas(this.initDatas.searchParams);
                    } else {
                        this.getAgentDatas(this.initDatas.listParams);
                    }
                }
            }
        })
    }

    @action("批量收回代理")
    takeBackAgent = (params) => {
        this.initDatas.isShowLoading = true;
        API.takeBackAgent(params).then(datas => {
            if (datas.flag) {
                const { flag = '' } = datas;
                Bubble.success(getLabel(130233,'收回成功！'), 2);
                this.initDatas.isShowLoading = false;
                this.initDatas.isShowCheck = false;
                this.getAgentDatas(this.initDatas.listParams);
            }
        })
    }
    @action("收回代理前的提问")
    takeBackPromptMsg = (params, Fun) => {
        API.takeBackPromptMsg(params).then(datas => {
            if (datas.promptmsg) {
                this.initDatas.promptmsg = datas.promptmsg;
                if (typeof Fun === "function") {
                    Fun(datas.promptmsg);
                }
            }
        })
    }

    @action("获取模板列表")
    agentTemplate = (params) => {
        // this.importFromTem.isShowLoading = true;
        API.agentTemplate(params).then(data => {
            const { datas = "" } = data;
            this.importFromTem.listViewPage_listsotre = new ListViewPage.Store({ route: '/agent/importFromTem', id: '/agent/importFromTem' });
            this.importFromTem.listViewPage_listsotre.getData({ dataKey: datas });
            this.importFromTem.listViewPage_listsotre.haveCheck = true;
        });
    }


    @action("模板管理")
    agentTemplateList = (params = {}) => {
        API.agentTemplateList({ ...params, ismobile: 1 }).then(results => {
            const { sessionkey = "" } = results;
            this.tempManagement.listViewPage_listsotre.data = [];
            this.tempManagement.listViewPage_listsotre = new ListViewPage.Store({ route: '/agent/temManagement', id: '/agent/temManagement' });
            this.tempManagement.listViewPage_listsotre.getData({ dataKey: sessionkey });
            this.tempManagement.isSelectedAll = false;
            this.tempManagement.selectedRowKeys = [];
        })
    }

    //请求模板管理数据
    searchTemplate = () => {
        if (JSON.stringify(this.tempManagement.searchParams) !== "{}") {
            this.agentTemplateList(this.tempManagement.searchParams);
        } else {
            this.setMobxStore({
                layout: new RouteLayout.Store({ route: "/agent/temManagement", id: "advanceSearch" }),
                searchPage_layout: new RouteLayout.Store({ route: "/agent/temManagement", id: "searchPage" }),
                searchValue: "",
            })
            this.initDatas.isAdVancedHasData = false;
            this.agentTemplateList();
        }
    }

    @action("模板管理高级搜索")
    agentTemplateCondition = () => {
        API.agentTemplateCondition({ ismobile: 1 }).then(results => {
            if (JSON.stringify(results) !== "{}") {
                const { conditioninfo = [] } = results;
                if (conditioninfo.length > 0) {
                    conditioninfo.map(item => {
                        if (item.title === getLabel(32905, "常用条件")) {
                            let arr = [];
                            for (let key in item.items) {
                                arr.push(item.items[key])
                            }
                            this.advancedItem.form.initForm([item], this.initDatas.nowPath + "/advanceSearch");
                            this.advancedItem.conditioninfo = [item];
                        }
                        return item;
                    })


                }
            }
        })
    }
    @action("编辑代理的保存")
    saveAgentDetail = (params, history) => {
        this.editAgent.isShowLoading = true;
        API.saveAgentDetail(params).then(results => {
            if (JSON.stringify(results) !== "{}") {
                const { agentresult = "" } = results;
                if (agentresult === "success") {
                    this.editAgent.isShowLoading = false;
                    Bubble.success(getLabel(18758,'保存成功'), 2);
                    this.editAgent.title = "";
                    this.editAgent.isShowCheckModal = false;
                    this.editAgent.radioChecked = 1;
                    history.push(this.editAgent.parentPath);
                    if (JSON.stringify(this.initDatas.searchParams) !== "{}") {
                        this.getAgentDatas(this.initDatas.searchParams);
                    } else {
                        this.getAgentDatas(this.initDatas.listParams);
                    }
                }
            }
        })
    }

    @action
    resetImportFromTem = () => {
        this.importFromTem.selectedRowKeys = "";
    }
}